/**
 * vuex 响应式状态管理
 */

import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    IP: false,
    language: 1, // 1 中文  2 英文  .....
    categoryId: false,
    player: {
      playerObj: false, // 插件播放对象
      playLoading: false, // 播放器是否已经加载音乐
      playModel: 1, // 播放模式   1 、 顺序循环播放   2 、 随机播放
      play: false, // 是否正在播放    1 播放 2 暂停 3 停止
      playId: false, // 当前播放的url
      playAllTime: false, // 歌曲总时长
      playTimeLine: false, // 当前播放时间
      playLrcArr: false, // 当前播放歌曲歌词数据
      playList: false // 播放列表
    },
    sysVolume: 0
  },
  mutations: {
    setIP(state, n) {
      state.IP = n;
    },
    setLanguage(state, n) {
      state.language = n;
    },
    setCategoryId(state, n) {
      state.categoryId = n;
    },
    setSysVolume(state, n) {
      state.sysVolume = n;
    },
    setPlayer(state, n) {
      switch (n[0]) {
        case 'playerObj':
          state.player.playerObj = n[1];
          break;
        case 'playAllTime':
          state.player.playAllTime = n[1];
          break;
        case 'playLoading':
          state.player.playLoading = n[1];
          break;
        case 'play':
          state.player.play = n[1];
          break;
        case 'playId':
          state.player.playId = n[1];
          break;
        case 'playTimeLine':
          state.player.playTimeLine = n[1];
          break;
        case 'playList':
          state.player.playList = n[1];
          break;
        case 'playLrcArr':
          state.player.playLrcArr = n[1];
          break;
        case 'playModel':
          state.player.playModel = n[1];
          break;
      }
    }
  },
  actions: {},
  getters: {
    getIP(state) {
      return state.IP;
    },
    getLanguage(state) {
      return state.language;
    },
    getCategoryId(state) {
      return state.categoryId;
    },
    getPlayer(state) {
      return state.player;
    },
    getSysVolume(state) {
      return state.sysVolume;
    }
  }
});
